#include <cvblobs/BlobResult.h>
#include "pixeltransform.h"
#include <vector>
#include <deque>

#include <ros/ros.h>

using namespace std;

typedef struct Blob
{
	cv::Point2d center;
	float area;
} Blob;


class detectedObject
{
public:
	detectedObject(cv::Point3d pos = cv::Point3d(), cv::Point2d screen = cv::Point2d())
		: mObjectPos(pos), screenPos(screen)
	{}

	cv::Point3d mObjectPos;
	cv::Point2d screenPos;
};


class BlobDetection
{
public:
	BlobDetection(ros::NodeHandle &n);

	void updateModel(const sensor_msgs::CameraInfoConstPtr &camInfo);

	void detectBlobs(cv::Mat &image);
	void filterImage(cv::Mat &image, vector<Blob> &detectedBlobs);
	void createObject(cv::Point2d blob);

	PixelTransform& GetTransform() { return pixelTransform; }

	vector<detectedObject>& GetObjects() { return mObjects; }

	void setHuecolorSpan(int hue, int span, int saturation);

private:
	Blob filterBlobPosition(Blob newBlob);

	PixelTransform pixelTransform;

	int mHueSpan;
	int mHueColor;
	int mSaturation;
	vector<detectedObject>mObjects;
	deque<Blob>mPrevBlobs;

};




